using System;
using UnityEngine;
using System.Collections.Generic;

namespace ABA
{
    public struct DataIntChange
    {
        public int fieldName;
        public bool isOnInit;
        public int oldValue;
        public int newValue;
    }
    public struct DataFloatChange
    {
        public int fieldName;
        public bool isOnInit;
        public float oldValue;
        public float newValue;
    }
    public struct DataBoolChange
    {
        public int fieldName;
        public bool isOnInit;
        public bool oldValue;
        public bool newValue;
    }
    public struct DataListChange
    {
        public int fieldName;
        public bool isOnInit;
        public object oldValue;
        public object newValue;
    }
    public struct DataStringChange
    {
        public int fieldName;
        public bool isOnInit;
        public string oldValue;
        public string newValue;
    }
    public struct DataLongChange
    {
        public int fieldName;
        public bool isOnInit;
        public long oldValue;
        public long newValue;
    }
    public struct DataDoubleChange
    {
        public int fieldName;
        public bool isOnInit;
        public double oldValue;
        public double newValue;
    }
    public struct DataObjChange
    {
        public int fieldName;
        public bool isOnInit;
        public object oldValue;
        public object newValue;
    }

    public enum E_NET_EVENT
    {
        None,
        Connected,
        MissHeartBeat,
        Error,
        CustomError,
        Closed,
        MsgData,
    }

    // Comm 用到的一些数据，Game必须设置
    public class CommData
    {
        public static int DESIGN_WIDTH = 1080;
        public static int DESIGN_HEIGHT = 2336;
        public static string YOOASSET_DEFAULT_PKG = "DefaultPackage";
        public static string YOOASSET_HOST_SERVER = "http://127.0.0.1";
        public static string YOOASSET_HOST_SERVER_VER = "v1.0";
        public static string MAIN_GAME_SCENE = "Game";
        public static string SYS_WIN_PKG_NAME = "sys";
        public static string PLAYER_PREFS_PREFIX = "ABA_";
        public static int EVENT_LOADING_BAR_UPDATE = 10000;


        //public static FGUIWinInfo WIN_SYS_BLOCK = new FGUIWinInfo
        //{
        //    cls_name = "none",
        //    pkg_name = "sys",
        //    comp_name = "block_event",
        //    zindex = E_FGUIWIN_ZINDEX.DIALOG,
        //    ani = false
        //};

        /// <summary>
        /// 获取资源服务器地址
        /// </summary>
        public static string GetHostServerURL()
        {
            //string hostServerIP = "http://10.0.2.2"; //安卓模拟器地址
            string hostServerIP = YOOASSET_HOST_SERVER;
            string appVersion = YOOASSET_HOST_SERVER_VER;

#if UNITY_EDITOR
            if (UnityEditor.EditorUserBuildSettings.activeBuildTarget == UnityEditor.BuildTarget.Android)
                return $"{hostServerIP}/CDN/Android/{appVersion}";
            else if (UnityEditor.EditorUserBuildSettings.activeBuildTarget == UnityEditor.BuildTarget.iOS)
                return $"{hostServerIP}/CDN/IPhone/{appVersion}";
            else if (UnityEditor.EditorUserBuildSettings.activeBuildTarget == UnityEditor.BuildTarget.WebGL)
                return $"{hostServerIP}/CDN/WebGL/{appVersion}";
            else
                return $"{hostServerIP}/CDN/PC/{appVersion}";
#else
            if (Application.platform == RuntimePlatform.Android)
                return $"{hostServerIP}/CDN/Android/{appVersion}";
            else if (Application.platform == RuntimePlatform.IPhonePlayer)
                return $"{hostServerIP}/CDN/IPhone/{appVersion}";
            else if (Application.platform == RuntimePlatform.WebGLPlayer)
                return $"{hostServerIP}/CDN/WebGL/{appVersion}";
            else
                return $"{hostServerIP}/CDN/PC/{appVersion}";
#endif
        }

    }
}
